package com.xiaotu.spider;

import net.sf.json.JSONObject;
import us.codecraft.webmagic.ResultItems;

import org.springframework.beans.factory.annotation.Autowired;
import com.xiaotu.common.exception.SpiderException;
import com.xiaotu.common.exception.SpiderExceptionCode;
import com.xiaotu.common.model.JobLogModel;
import com.xiaotu.common.model.SpiderLogModel;
import com.xiaotu.common.util.CacheHandler;

public abstract class AHttpProcessor
{
	@Autowired
	protected CacheHandler cacheHandler;
	
	private SpiderLogModel spiderLog;
	
	public void setTaskInfo(SpiderLogModel spiderLog)
	{
		this.spiderLog = spiderLog;
	}
	
	/**
	 * 执行获取http请求返回的结果
	 * @return JSONObject 获取到的数据结果
	 */
	public abstract void process(JSONObject target, ResultItems resultItems);
	
	/**
	 * 获取爬虫任务的类型
	 * @return 任务类型标识
	 */
	public abstract String getSpiderType();
	
	/**
	 * 获取页面数据的类型
	 * @param page 爬取页面
	 * @return 类型标识
	 */
	public abstract String getPageDataType();
	
	public SpiderLogModel getSpiderLog()
	{
		return spiderLog;
	}
}
